package jzqb.controller;

import haha.life.common.CutPageBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jzqb.bo.NoticeBo;
import jzqb.common.Result;
import jzqb.service.INoticeService;
import jzqb.vo.NoticeVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * Description:
 *
 * @author BaiGe
 * @date: 2021/4/25 10:43
 * @Version 1.0
 */
@Api(tags = "系统公告-前台")
@RestController
@RequestMapping("/systemNotice")
public class SystemNoticeController {
    @Autowired
    private INoticeService noticeService;

    @ApiOperation(value = "首页展示5条系统公告")
    @PostMapping("/showIndexPageSystemNotice")
    private Result showSystemNoticeOfIndexPage(){
        List<NoticeVo> noticeList = noticeService.showSystemNoticeLimitFive();
        return  Result.succ(noticeList);
    }

    @ApiOperation(value = "查询系统公告-前台")
    @PostMapping("/querySystemNotice")
    private Result querySystemNotice(@RequestBody NoticeBo noticeBo){
        noticeBo.setStart(noticeBo.getPage(), noticeBo.getPageSize());
        CutPageBean<NoticeVo> cutPageBean = noticeService.showSystemNotice(noticeBo);
        return  Result.succ(cutPageBean);
    }

    @ApiOperation(value = "系统公告详情页 -前台")
    @PostMapping("/systemNoticeInfo")
    private Result systemNoticeInfo(@RequestBody NoticeBo noticeBo){
        NoticeVo notice = noticeService.findSystemNoticeById(noticeBo.getId());
        return  Result.succ(notice);
    }

}
